import java.util.*;

import sdljava.SDLException;
import sdljava.event.SDLEvent;
import sdljava.video.*;

public class Location {
	protected SDLSurface locationImage;
	protected Vector<Sprite> sprites;
	protected Vector<ButtonSprite> buttons;
	protected GameWindow gameWindow;
	protected static int vertical = 0;
	protected static int horizontal = 1;
	protected int changeLocation = 0;
	protected CharacterSprite chosenCharacter;
	
	public Location(){}
	public Location(GameWindow gameWindow, String imageFile) throws SDLException{
		this.gameWindow = gameWindow;
		this.locationImage = loadfile(imageFile);
		sprites = new Vector<Sprite>();
		buttons = new Vector<ButtonSprite>();
		//show(locationImages);
	}
	public void handleEvent(SDLEvent event)throws SDLException{
		
	}
	public SDLSurface loadfile(String filename) throws SDLException{
		SDLSurface loadedImage = null;
		loadedImage = SDLVideo.loadBMP(filename);
		SDLSurface optimizedImage = loadedImage.displayFormat();
		loadedImage.freeSurface();
		return optimizedImage;
	}
	
	protected void show() throws SDLException{
		locationImage.blitSurface(gameWindow.getGameSurface());
		showButtonSprites();
		gameWindow.getGameSurface().flip();
	}
	public int doubleToInt(double changeMe){
		if((int)changeMe != (int)(changeMe+0.5)){
			return ((int)changeMe + 1);
		}
		return (int)changeMe;
	}
	public int getChangeLocation() {
		return changeLocation;
	}
	public void setChangeLocation(int current) {
		// TODO Auto-generated method stub
		this.changeLocation = current;
	}
	public void showButtonSprites() throws SDLException{
		for(int i = 0; i < buttons.size(); i++){
			buttons.get(i).show(buttons.get(i).getSpriteImage().get(0));
		}
	}
	public void setChosenCharacter(CharacterSprite chosenCharacter) {
		this.chosenCharacter = chosenCharacter;
	}

	public CharacterSprite getChosenCharacter() {
		return chosenCharacter;
	}
	public Construction getConstruction(){
		return null;
	}
	public void repopulateCVector() throws SDLException{
	}
}
